﻿using System;
using OS.Infrastructure.Domain;

namespace TaskKernel.Domain
{
    public class Reminder : AbstractEntity
    {
        protected Reminder()
        {
        }

        public Reminder(Task task, Account owner, DateTime dateTime, string note)
            : this()
        {
            Task = task;
            Owner = owner;
            DateTime = dateTime;
            Note = note;
        }

        public virtual Account Owner { get; protected set; }
        public virtual Task Task { get; protected set; }
        public virtual DateTime DateTime { get; protected set; }
        public virtual string Note { get; protected set; }

        public override int GetHashCode()
        {
            int hashCode = 0;
            hashCode = hashCode ^ Owner.GetHashCode() ^ DateTime.GetHashCode() ^ Note.GetHashCode();
            return hashCode;
        }

        public override bool Equals(object obj)
        {
            var toCompare = obj as Reminder;
            if (toCompare == null)
                return false;
            return (GetHashCode() == toCompare.GetHashCode());
        }

        public virtual string GetDate()
        {
            return Tools.ddMMyyyyToString(DateTime);
        }

        public virtual int GetHour()
        {
            return DateTime.Hour;
        }

        public virtual int GetMinute()
        {
            return DateTime.Minute;
        }
    }
}